define(['jquery', 'bootstrap', 'frontend', 'form', 'template', 'cookie', 'frontend/xiao_man_yao', 'frontend/whiteboard', 'frontend/loginpop', 'frontend/password_verified'], function ($, undefined, Frontend, Form, Template, cookie_class, XiaoManYao, WhiteBoard, LoginPop, PasswordVerified) {

    var Controller = {
        ai_url: Config.ai_url,

        //AI首页
        index: function () {

            //初始化密码验证
            PasswordVerified.init();


            //如果没有登陆,就弹出登陆窗口
            if (LoginPop.logined == 0) {
                LoginPop.callback_url="/index/ai/index";
                LoginPop.openLoginWindow();
                return false;
            }

            $(".loading").css("display", "block");
            var url1 = Controller.ai_url + "sitecode=gsq4&token=" + LoginPop.cross_site_token;
            console.log("ai_url", url1);
            var str = '<iframe id="fullscreen_ai"   src="' + url1 + '" >正在加载AI馆，请等待。。。。。</iframe>';
            $(".container").html(str);

            $('#fullscreen_ai').on('load', function () {
                // iframe加载完成后的操作
                console.log('iframe加载完成');
                $(".loading").css("display", "none");
            });

        },

        //弹出AI查询结果
        ai_result: function () {
        },

        //弹出登陆窗口
        loginpop: function () {
            Form.api.bindevent($("form[role=form]"), function (data, ret) {
                Fast.api.close(data);
                // Toastr.success("登陆成功");
            }, function (data, ret) {
                // Toastr.error("登陆失败");
            });
        },

        //弹出密码验证窗口
        passwordpop: function () {
            Form.api.bindevent($("form[role=form]"), function (data, ret) {
                Fast.api.close(data);
                // Toastr.success("登陆成功");
            }, function (data, ret) {
                // Toastr.error("登陆失败");
            });
        }
    };
    return Controller;
});
